<?php
if(isset($formData)):
    $modules=$formData['modules'];
    $moduleNames=$formData['moduleNames'];
endif;

if($NewDmd):
    echo $this->Form->create()
        ?><fieldset><legend><?php __('Demand type')  ?></legend><?php        
        echo $this->Form->input('dmdformtype_id',array('type'=>'radio','between'=>'<ul><li>','after'=>'</li></ul>','separator'=>'</li><li>','options'=>$types,'default'=>'1','legend'=> false,'class'=>'demandType'));
?></fieldset><?php        
    echo $this->Form->end('submit');

else: ?>
    <!--*****************  LEFT  *****************-->
      <div class="columnLeft">
          <div class="content">
              <!--*****************  MENU  *****************-->
              <div class="contentMenu">

                  <div class="contentMenuItems">
                      <ul>
                          <li class="contentMenuTitle">Actions</li>
                          <li class="contentMenuSeparator"></li>
                          <?php $nbModule=1;  foreach($modules as $mnb => $m): ?>
                          <li><a id="rub<?php echo $nbModule ?>" class="formRub<?php if($nbModule==1){echo " active";}  ?>" href="<?php  echo $nbModule ?>"><?php  __($moduleNames[$mnb]); ?></a></li>
                          <li class="contentMenuSeparator"></li>
                          <?php $nbModule++;endforeach;  ?>
                          <li><a id="rub<?php echo $nbModule ?>" class="formRub" href="<?php  echo $nbModule ?>"><?php __('Validate')  ?></a></li>
                          <li class="contentMenuSeparator"></li>
                          <li class="contentMenuBottom"></li>
                      </ul>
                  </div>

              </div>
          </div>
      </div>
<!--*****************  RIGHT  *****************-->
      <div class="columnRight">
          <div class="content">
              <div class="contentCenter">
                  <?php
                  
                      if(!empty($modifyForm) && $modifyForm==1){ 
                          echo $this->Form->create(null,array('action'=>'updateDmdform'));
                      }else{
                         echo $this->Form->create(null,array('action'=>'saveDmdform'));
                      }  
                  
                  ?>
                  <div class="isHidden">
                      
                  <?php echo $this->Form->input('dmdformtype_id',array('type'=>'text','default'=>$formData['type']));  ?>
                  <?php echo $this->Form->input('id');  ?>
                  <?php echo $this->Form->input('code');  ?>
                      
                  </div>
                  <div class="prmdform">
                    <?php 
                        $nbModule=1;
                        foreach ($modules as $m):
                            echo '<div id="prmdf'.$nbModule.'" class="prmdf">';
                            include $this->Camelcase->from_camel_case($m).'.ctp';                            
                    ?>                     
                    <table>
                        <tbody>
                            <tr>
                                <?php if($nbModule>1):  ?>
                                    <td style="width:600px;">
                                        <div class="prevPrmdf"><<</div>
                                    </td>
                                <?php endif;  ?>
                                    <td>
                                        <div class="nextPrmdf ">>></div>
                                    </td>
                            </tr>
                        </tbody>
                    </table>
                  
                  <?php
                            echo '</div>';
                            $nbModule++;
                        endforeach;
                  ?>
                    <div id="prmdf<?php  echo $nbModule ?>" class="prmdf">
                        <?php  echo $this->Form->submit(__('Submit',true)) ?>

                        <table>
                            <tbody>
                                <tr>
                                    <td style="width:600px;">
                                        <div class="prevPrmdf"><<</div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
              </div>
                  <?php echo $this->Form->end();  ?>
              </div>
          </div>
      </div>
<script type="text/javascript">
    $(document).ready(function(){
        prmdform.init($('.prmdform'),'.formRub');
    });
    
</script>
<?php  endif; ?>